package com.huadi.ssm.Controller;

import com.huadi.ssm.Service.EvidenceService;
import com.huadi.ssm.Service.IdentifyService;
import com.huadi.ssm.po.Identifyrecord;
import com.huadi.ssm.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/identify")
public class IdentifyController {
@Autowired
    @Qualifier("IdentifyImpl")
    private IdentifyService identifyService;

@Resource
private EvidenceService evidenceService;
//显示所有的鉴定记录
@RequestMapping("/allidentify")
    public String allidentify(Model model){

    List<Identifyrecord> identifyrecord=identifyService.findAllIdentifyrecord();
    model.addAttribute("identifyrecord", identifyrecord);
    return "allIdentifyRec";
}


//进入到鉴定物证的界面
    @RequestMapping("/toIdentify")
    public String toIdentify(){return "identify";}

    //鉴定物证
    @RequestMapping("/Identify")
    public String Identify(String evidenceId, String evidenceIdentifyResult, HttpSession session){
    User user=(User)session.getAttribute("user");
    evidenceService.Identify(evidenceId,evidenceIdentifyResult);
    identifyService.addIdentifyrecord(evidenceId,evidenceIdentifyResult,user.getUserId(),user.getUsername());
    return "redirect:/evidence/TechnicianGetEvi";
    }


}
